using SqlSugar;
using System.ComponentModel.DataAnnotations;

namespace Rabbit3.Api.Models
{
    /// <summary>
    /// 养殖信息表
    /// </summary>
    [SugarTable("farming_info")]
    public class FarmingInfo
    {
        /// <summary>
        /// 主键ID
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }

        /// <summary>
        /// 溯源信息ID
        /// </summary>
        [SugarColumn(IsNullable = false)]
        [Required(ErrorMessage = "溯源信息ID不能为空")]
        public int TraceabilityId { get; set; }

        /// <summary>
        /// 品种
        /// </summary>
        [SugarColumn(ColumnDataType = "varchar(30)", IsNullable = false)]
        [Required(ErrorMessage = "品种不能为空")]
        [StringLength(30, ErrorMessage = "品种长度不能超过30个字符")]
        public string Breed { get; set; } = string.Empty;

        /// <summary>
        /// 来源
        /// </summary>
        [SugarColumn(ColumnDataType = "varchar(30)", IsNullable = false)]
        [Required(ErrorMessage = "来源不能为空")]
        [StringLength(30, ErrorMessage = "来源长度不能超过30个字符")]
        public string Source { get; set; } = string.Empty;

        /// <summary>
        /// 饲养天数
        /// </summary>
        [SugarColumn(IsNullable = false)]
        [Required(ErrorMessage = "饲养天数不能为空")]
        [Range(1, 99999, ErrorMessage = "饲养天数必须在1-99999之间")]
        public int FarmingDays { get; set; }

        /// <summary>
        /// 饲料品牌
        /// </summary>
        [SugarColumn(ColumnDataType = "varchar(30)", IsNullable = false)]
        [Required(ErrorMessage = "饲料品牌不能为空")]
        [StringLength(30, ErrorMessage = "饲料品牌长度不能超过30个字符")]
        public string FeedBrand { get; set; } = string.Empty;

        /// <summary>
        /// 饲养负责人
        /// </summary>
        [SugarColumn(ColumnDataType = "varchar(30)", IsNullable = false)]
        [Required(ErrorMessage = "饲养负责人不能为空")]
        [StringLength(30, ErrorMessage = "饲养负责人长度不能超过30个字符")]
        public string FarmingManager { get; set; } = string.Empty;

        /// <summary>
        /// 出栏日期
        /// </summary>
        [SugarColumn(IsNullable = false)]
        [Required(ErrorMessage = "出栏日期不能为空")]
        public DateTime ReleaseDate { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public DateTime CreatedAt { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public DateTime UpdatedAt { get; set; } = DateTime.Now;

        /// <summary>
        /// 是否删除
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public bool IsDeleted { get; set; } = false;

        /// <summary>
        /// 创建人ID
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public int? CreatedBy { get; set; }

        /// <summary>
        /// 更新人ID
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public int? UpdatedBy { get; set; }

        /// <summary>
        /// 导航属性 - 溯源信息
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public TraceabilityInfo? TraceabilityInfo { get; set; }
    }
}


